package com.yanqu.road.server.logic.activity.condition.liveshow;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseActivityCondition;
import com.yanqu.road.utils.date.DateHelper;

import java.math.BigInteger;

public class LiveShowDailyTimeCondition extends BaseActivityCondition {

    public LiveShowDailyTimeCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.LiveShowDailyTime.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.LiveShowDailyTime.getValue(), handle);
    }

    @Override
    public boolean isCompleted(GamePlayer player) {
        BigInteger param4 = activityConditionInfo.getParamList().get(3);
        if(getValue().compareTo(param4.multiply(BigInteger.valueOf(DateHelper.MINUTE_MILLIONS))) >= 0){
            return true;
        }
        return false;
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        long args = (long) object;
        BigInteger value = BigInteger.valueOf(args);
        setValue(value);
    }
}
